module.exports = function() {
	let {
		mainComp,
	} = $['components-jq']
	let treeJQ = mainComp.treeJQ = $("#main-tree")
	treeJQ.tree({
		data: [{
			id: 'main-user',
			text: "用户管理",
			attributes: {
				title: 'user Man',
				content(resolve) {
					import('@jviews/user/user.html').then(resolve)
				},
			},
		}, {
			id: 'main-team',
			text: "团队管理",
			attributes: {
				title: 'team Man',
				content: '<div id="main-tabs-team"></div>',
			},
		}, {
			id: 'main-project',
			text: "项目管理",
			attributes: {
				title: 'project Man',
				content(resolve) {
					import('@jviews/project/project.html').then(resolve)
				},
			},
		}, {
			id: 'main-apis',
			text: "Node 2",
			attributes: {
				title: 'apis Man',
				content: '<div id="main-tabs-apis"></div>',
			},
		}, {
			id: 'main-params',
			text: "Node 2",
			attributes: {
				title: 'params Man',
				content: '<div id="main-tabs-params"></div>',
			},
		}],
		onClick(node) {
			let {
				title,
				content,
			} = node.attributes
			let tabsJQ = mainComp.tabsJQ
			if (tabsJQ.tabs('exists', title)) {
				tabsJQ.tabs('select', title)
				return
			}
			if (typeof content == 'function') {
				content(html => {
					tabsJQ.tabs('add', {
						id: node.id,
						title: title,
						content: html,
						closable: true,
					})
				})
				return
			}
			tabsJQ.tabs('add', {
				id: node.id,
				title: title,
				content,
				closable: true,
			})
		},
	});
}